widget: Clarify some corner cases
authorBenjamin Otte <otte@redhat.com>
Sat, 29 Nov 2014 00:55:06 +0000 (01:55 +0100)
committerBenjamin Otte <otte@redhat.com>
Sat, 29 Nov 2014 02:42:28 +0000 (03:42 +0100)
I checked Cairo source code (actually pixman, as Cairo just passes
through) to make sure that the behavior stays identical: negative values
cause an error message from pixman, zero is allowed. Both return an
empty region which gtk_widget_queue_draw_region() would then proceed to
ignore.

gtk/gtkwidget.c

index 7ff1aff3f0fd23a2e28e13c7493b5e88d7ac8de1..0be027207015dd23b1a94730ace02749e1213ab6 100644 (file)
@@ -5657,6 +5657,9 @@ gtk_widget_queue_draw_region (GtkWidget            *widget,
  * defined as @widget->window coordinates for widgets that are not
  * #GTK_NO_WINDOW widgets, and are relative to @widget->allocation.x,
  * @widget->allocation.y for widgets that are #GTK_NO_WINDOW widgets.
+ *
+ * @width or @height may be 0, in this case this function does
+ * nothing. Negative values for @width and @height are not allowed.
  */
 void
 gtk_widget_queue_draw_area (GtkWidget *widget,
@@ -5669,6 +5672,11 @@ gtk_widget_queue_draw_area (GtkWidget *widget,
   cairo_region_t *region;
 
   g_return_if_fail (GTK_IS_WIDGET (widget));
+  g_return_if_fail (width >= 0);
+  g_return_if_fail (height >= 0);
+
+  if (width == 0 || height == 0)
+    return;
 
   rect.x = x;
   rect.y = y;